import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Text And Font',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyStatelessWidget(),
    );
  }
}

class MyStatelessWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    //定义文本样式
    const styles = TextStyle(
      //16进制颜色，前两位透明度，后六位颜色
      color: const Color(0xffff0000),
      //color: Colors.yellow,
      fontSize: 20,
      fontFamily: "yahei",
      decoration: TextDecoration.underline,
      decorationStyle: TextDecorationStyle.dotted
    );
    return Scaffold(
      appBar: AppBar(
        title: Text("Text And Font1"),
      ),
      body: Column(
        children: <Widget>[
          //内联元素没有宽高，
          Text("hello bodyhello bodyhello bodyhello bodyhello bodyhellobodyhellobodyhellobodyhellobodyhellobodyhello bodybodyhellobodyhellobodyhellobodyhellobodyhellobodyhellohello body",
            //文本对齐方式
            textAlign: TextAlign.center,
            //最多显示多少行
            maxLines: 2,
            //超过最多行数显示出省略号
            overflow: TextOverflow.ellipsis,
            //字体放大缩小多少倍
            textScaleFactor: 1,
          ),
          Text("样式测试",
          style: styles,),
          //分段设置样式
          Text.rich(TextSpan(
            children: [
              TextSpan(
                text: "主页:",
                style: TextStyle(
                    color: Colors.red,
                    fontSize: 25
                )
              ),
              TextSpan(
                text: "https://www.baidu.com",
                style: TextStyle(
                  color: Colors.yellow,
                  fontSize: 25
                )
              )
            ]
          ))
        ],
      ),
    );
  }

}
